<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>{$Think.config.site.title} - 广告管理</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
      <form method="get" class="form-horizontal">
      <div class="row">
          <div class="col-sm-7">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>广告信息</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                      	</div>
                    </div>
                    <div class="ibox-content">
                        
                        <input type="hidden" name="brand_id" value="" />
                      
                            <div class="form-group">
                                <label class="col-sm-3 control-label">品牌名</label>
                                <div class="col-sm-9">
                                    <input id="brand_name" name="brand_name" class="form-control" type="text" value="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">品牌排序</label>
                                <div class="col-sm-9">
                                    <input id="brand_sort" name="brand_sort" class="form-control" type="text" value="">

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">品牌简介</label>
                                <div class="col-sm-9">
                                    <textarea id="brand_desc" name="brand_desc" class="form-control"></textarea>
                                </div>
                            </div>
  
                            <div class="form-group">
                                <label class="col-sm-3 control-label">状  态：</label>
                                <div class="col-sm-9">
                                	<label for="statustrue">开启</label>
                                    <input id="statustrue" name="brand_status" class="form-control"  type="radio" value="1" checked>
                                    <label for="statusfalse">关闭</label>
                                    <input id="statusfalse" name="brand_status" class="form-control"  type="radio" value="0" >
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-5 col-sm-offset-3">
     
                                    <input type="submit" class="btn btn-primary" value="提交">
                           
                                </div>
                            </div>
                        
                    </div>
                </div>
            </div>
            <div class="col-sm-5">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>品牌LOGO</h5> 
						<div class="ibox-tools">
							<a class="collapse-link">
							<i class="fa fa-chevron-up"></i>
							</a>
						</div>
					</div>
					<div class="ibox-content">
						<p>
							<button type="button" class="btn btn-primary btn-sm col-sm-12" up-img="brand_logo" id="brand_logo" url="{:url('Upload/index')}" auto='true' success="upsuccess" error="uperror" value="">上传图片</button>
						</p>
						<p><img id="show_brand_logo" alt="image"  src="" style="max-width: 100%;" /></p>
					</div>
				</div>
          </div>
        </div>
        </form>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
  	<script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
  	<script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
  	<script src="{$Think.config.site.common_resource_url}js/majax.js"></script>
  	<script src="{$Think.config.site.common_resource_url}js/laydate/laydate.js"></script>
</body>

</html>
<script>
function upsuccess(d){
	if (d.code>0) {
		$('#show_brand_logo').attr('src',d.data);
	}else{
		layer.msg(d.msg, {icon: 5});
	}
}
function uperror(e){
	layer.msg('网络出错！', {icon: 5});
}

$(document).ready(function(){

	$("input").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});

	$("form").validate({
	  debug:true,
	  submitHandler:function(form){
            save();   
      },    
	  rules: {
		brand_name: {
		  required: true,
		},
		brand_sort: {
		  number:true,
		},

	  },
	  messages: {
		brand_name: {
		  required: '广告名必须填写',
		},
		brand_sort: {
		  number: '只能输入数字',
		},
	  }
	});

	function save(){
		var fomrData = $("form").serialize();

		majax('{:url("add")}',fomrData,function(d){
			if (d.code>0) {
				window.parent.editSuccess(d);
			}else{
				layer.msg(d.msg, {icon: 5});
			}
		})
	};
})
</script>